home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.3d26 source / SPPC / sppcinit.c < prev    next >
Text File  |  1991-05-28  |  2KB  |  73 lines

  1. #if !defined(USEDUMP)
  2.     #include "sppclib.h"
  3. #else
  4.     #pragma load "sppcDumpFile"
  5. #endif
  6.  
  7. #define GOODICON    128        /* success ICON resource number */
  8. #define BADICON        129        /* failure ICON resource number */
  9. #define DRIVERNAME    "\p.SPPC"    /* name of our driver */
  10.  
  11. extern pascal void ShowINIT(short iconID, short moveX);
  12.  
  13. void sppcinit()
  14. {
  15. DCtlHandle **utp;    /* pointer to unit table */
  16. DCtlHandle *ut;        /* unit table array */
  17. short *utsize;        /* size of array */
  18. short i, slotnum;
  19. Handle reshandle;
  20. OSErr rc;
  21. short rid;
  22. ResType rtype;
  23. unsigned char rname[256];
  24.  
  25. /* Search the unit table for an open slot in which to install
  26.    our driver.  Search backwards from the end.  If no slot is
  27.    found, exit with the error icon */
  28.    
  29. utp = (DCtlHandle **)UTableBase;
  30. ut = *utp;
  31. utsize = (short *)UnitNtryCnt;
  32. slotnum = 0;
  33. for (i = (*utsize)-1; i >= 1; i--) {
  34.     if (ut[i] == 0) {
  35.         slotnum = i;
  36.         break;
  37.         }
  38.     }
  39. if (slotnum == 0) {
  40.     ShowINIT(BADICON, -1);
  41.     return;
  42.     }
  43.  
  44. /* Attempt to load our driver */
  45. reshandle = GetNamedResource('DRVR', DRIVERNAME);
  46. rc = ResError();
  47. if (rc != noErr) {
  48.     ShowINIT(BADICON, -1);
  49.     return;
  50.     }
  51. if (reshandle == 0) {
  52.     ShowINIT(BADICON, -1);
  53.     return;
  54.     }
  55.  
  56. /* Change resource id to open slot */
  57. GetResInfo(reshandle, &rid, &rtype, rname);
  58. SetResInfo(reshandle, slotnum, rname);
  59.  
  60. /* Open the driver */
  61. OpenDeskAcc(DRIVERNAME);
  62.  
  63. /* Ensure driver undisturbed */
  64. DetachResource(reshandle);
  65.  
  66. /* Restore previous slot in file */
  67. reshandle = GetNamedResource('DRVR', DRIVERNAME);
  68. SetResInfo(reshandle, rid, 0);
  69.  
  70. /* Display success icon and return */
  71. ShowINIT(GOODICON, -1);
  72. }
  73.